<template>
  <div class="Order">
    <h2>订单管理</h2>
    <div class="top_inputl">
      <div class="tab-inp">
        <div class="bre">
          订单类型
          <el-select v-model="value" placeholder="请选择">
            <el-option
              v-for="item in tableData"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <div class="bre">
          <b>搜索:</b>
          <el-input
            v-model="input"
            placeholder="请输入手机号/用户名/订单号"
          ></el-input>
        </div>
        <el-button type="info" @click="sousuor">查询</el-button>
      </div>
    </div>
    <el-table
      :data="tableData"
      style="width: 100%"
      :header-cell-style="{ background: '#efefef', color: '#606266' }"
    >
      <el-table-column prop="id" label="序号" width="180"> </el-table-column>
      <el-table-column prop="name" label="用户名" width="180"> </el-table-column>
      <el-table-column prop="price" label="手机号"> </el-table-column>
       <el-table-column prop="name" label="类型" width="180"> </el-table-column>
      <el-table-column prop="price" label="支付金额" width="180"> </el-table-column>
      <el-table-column prop="time" label="支付时间"> </el-table-column>
      <el-table-column
      fixed="right"
      label="操作"
      width="120">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="deleteRow(scope.row.id)"
          type="text"
          size="small">
          删除
        </el-button>
      </template>
    </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  data() {
    return {
      tableData:[],
      value: "",
      input: "",
    };
  },
  created(){
    axios.get("http://127.0.0.1:7001/getList").then(res=>{
      this.tableData=res.data.data
    })
  },
  methods:{
    deleteRow(id){
      axios.delete(`http://127.0.0.1:7001/delete/${id}`).then(res=>{
        this.$router.go("0")
      })
    },
    sousuor(){
      axios.get(`http://127.0.0.1:7001/getList/?keyword=${this.input}`).then(res=>{
        this.tableData=res.data.data
      })
    }
  }
};
</script>

<style scoped lang="scss">
.Order {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.el-table__header {
  background: #efefef;
}
.colgroup {
  background: #efefef;
}
</style>
